package com.situ.project1.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.situ.project1.mapper.CarMapper;
import com.situ.project1.mapper.OrderMapper;
import com.situ.project1.pojo.Order;
import com.situ.project1.service.OrderService;
import com.situ.project1.util.PaginateInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author:yzy
 * @date:2024/8/10
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private CarMapper carMapper;



    private OrderMapper orderMapper;

    @Autowired
    public OrderServiceImpl(OrderMapper orderMapper) {
        this.orderMapper = orderMapper;
    }

    @Override
    public List<Order> findAll(PaginateInfo pi, Order order) {
        try (Page<Object> __ = PageHelper.startPage(pi.getPageNo(), pi.getPageSize())){
            return orderMapper.findAll(order);
        }
    }

    @Override
    public boolean add(Order order) {
        return orderMapper.add(order);
    }

    @Override
    public boolean update(Order order) {
//        System.out.println(order.getId());
        return orderMapper.update(order);
    }

    @Override
    public boolean delete(Integer[] ids) {
        return orderMapper.delete(ids);
    }

    @Override
    public Order findEarliest(String orderId) {
        System.out.println(orderId);
        return orderMapper.findEarliest(orderId);
    }

    @Override
    public boolean deleteById(Integer id) {
        return orderMapper.deleteById(id);
    }

    @Override
    public boolean finish(String id, String model) {
        return orderMapper.finish(id,model);
    }
}
